/* Copyright 2008 Bas van den Berg
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "yaffut.h"
#include "myassert.h"
#include "TestSession.h"

#include "Utils.h"
#include "Room.h"
#include "MudPlayer.h"
#include "config.h"


using namespace Chronos;
using namespace std;

struct UtilsTest {
};


TEST(UtilsTest, testItoa) {
    ASSERT_STR_EQUAL("0", Utils::itoa(0));
    ASSERT_STR_EQUAL("10", Utils::itoa(10));
    ASSERT_STR_EQUAL("255", Utils::itoa(255));
    ASSERT_STR_EQUAL("1234560", Utils::itoa(1234560));
}


TEST(UtilsTest, testItoaSigned) {
    ASSERT_STR_EQUAL("0", Utils::itoa((int)0));
    ASSERT_STR_EQUAL("10", Utils::itoa((int)10));
    ASSERT_STR_EQUAL("255", Utils::itoa((int)255));
    ASSERT_STR_EQUAL("1234560", Utils::itoa((int)1234560));
	ASSERT_STR_EQUAL("-10", Utils::itoa((int)-10));
	ASSERT_STR_EQUAL("-255", Utils::itoa((int)-255));
	ASSERT_STR_EQUAL("-1234560", Utils::itoa((int)-1234560));
}


TEST(UtilsTest, testDurationString) {
    ASSERT_STR_EQUAL("0d0h0m0s", Utils::toDurationString(0));
    ASSERT_STR_EQUAL("0d0h10m20s", Utils::toDurationString(minutes(10) + seconds(20)));
    ASSERT_STR_EQUAL("0d3h59m1s", Utils::toDurationString(hours(3) + minutes(59) + seconds(1)));
    ASSERT_STR_EQUAL("2d23h59m1s", Utils::toDurationString(2*hours(24) + hours(23) + minutes(59) + seconds(1)));
}

